package com.hoan.component.kotlin

import android.util.Log
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext

fun main() {

    GlobalScope.launch(Dispatchers.Main) {
        val user = getUserInfo()
        Log.e("haha", user)
        val friendList = getFriendList(user)
        Log.e("haha", friendList)
        val feedList = getFeedList(friendList)
        Log.e("haha", feedList)
    }
}

suspend fun getUserInfo(): String {
    withContext(Dispatchers.IO) {
        delay(2000L)
    }
    return "BoyCoder"
}

suspend fun getFriendList(user: String): String {
    withContext(Dispatchers.IO) {
        delay(2000L)
    }
    return "Tom, Jack"
}

suspend fun getFeedList(list: String): String {
    withContext(Dispatchers.IO) {
        delay(2000L)
    }
    return "{FeedList..}"
}
